package cn.tedu.store.controller;

import cn.tedu.store.common.ApiResult;
import cn.tedu.store.entity.Switch;
import cn.tedu.store.service.Switchseivice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/switch")
public class SwitchController {


    @Resource
    Switchseivice switchseivice;
    @GetMapping("add")
    public void  add(String name, String status){
        switchseivice.add(name,status);
    }

    @GetMapping("get")
    public Switch get(String phone){
        return switchseivice.get(phone);
    }
    @GetMapping("update")
    public ApiResult update(String phone,String status){
        switchseivice.update(phone,status);
      return   ApiResult.ok();
    }

    @GetMapping("add1")
    public ApiResult add1(String phone,String name){
        switchseivice.add1(phone, name);
        return ApiResult.ok();
    }
    @GetMapping("all")
    public ApiResult all(){
       List<Switch> switches = switchseivice.getAll();
        return ApiResult.ok(switches);
    }
}
